




/*
*************************************************************************
*西瑞克斯研发管理系统
*版 本: 1.0   
*日 期：02/25/2012    
*作 者： 王浩 QQ：873987060   
*************************************************************************   
*/ 
package com.application.yfprojectteams.struts.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.manager.commons.config.ConfigFactory;
import com.manager.commons.page.PageBean;
import com.manager.commons.RandomKey;
import com.manager.commons.CommonUtil;
import com.application.yfprojectteams.entity.YfProjectTeams;
import com.application.yfprojectteams.struts.form.YfProjectTeamsForm;
import com.application.yfprojectteams.service.YfProjectTeamsService;
import com.application.yfprojectteams.commons.Constants;
 /**
 * 
 * Description:YfProjectTeamsAction<br />
 * 
 * Version:V0.1<br />
 * 
 * Author: 王浩 QQ：873987060    <br />
 * 
 * History: <br />
 * 
 * 02/25/2012 
 * 
 */
public class YfProjectTeamsAction extends DispatchAction
{
       
       /**
	 * Service层实例
	 */
	private YfProjectTeamsService yfProjectTeamsService;

	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * 实体对象
	 */
        private YfProjectTeams yfProjectTeams;


        /**
	 * 采用partialList方式分页程序
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public ActionForward getYfProjectTeamsPartialList(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("searchYfProjectTeams" + "开始");
		YfProjectTeamsForm yfProjectTeams = (YfProjectTeamsForm)form;
		// 统计总记录数的sql语句
		int resultSize = 0;
		// 初始化pageBean供分页所用
		PageBean pageBean = null;
		// 取得当前页list数据
		List yfProjectTeamsList = null;
		resultSize = yfProjectTeamsService.getAllCountYfProjectTeams(yfProjectTeams);
		pageBean = PageBean.getPageBean("yfProjectTeamsTab", resultSize,request);
		yfProjectTeamsList = yfProjectTeamsService.searchYfProjectTeams(yfProjectTeams,pageBean);
		request.setAttribute("yfProjectTeamsList", yfProjectTeamsList);

		log.debug("searchYfProjectTeams" + "结束");

		return mapping.findForward(Constants.SUCCESS);
	}

        /**
	 * 到达新增页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toAddYfProjectTeams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toAddYfProjectTeamss");
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 增加
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward addYfProjectTeams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("addYfProjectTeamss");
		YfProjectTeams yfProjectTeams = this.getYfProjectTeams(form);
                yfProjectTeams.setId(RandomKey.generateID_Long_19());
		 yfProjectTeams.setOperateid(CommonUtil.getCurrentUser(request).getId());
		 yfProjectTeams.setCreateDate(new Date());

		this.yfProjectTeamsService.insertObject(yfProjectTeams);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 删除
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward deleteYfProjectTeams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("deleteYfProjectTeamss");
		YfProjectTeamsForm yfProjectTeamsForm = (YfProjectTeamsForm) form;
		this.yfProjectTeamsService.deleteYfProjectTeamss(yfProjectTeamsForm);
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 到达更新页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toUpdateYfProjectTeams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toUpdateYfProjectTeamss");

		YfProjectTeams yfProjectTeams = this.getYfProjectTeams(form);
		yfProjectTeams = this.yfProjectTeamsService.getYfProjectTeams(yfProjectTeams);
		request.setAttribute(Constants.YFPROJECTTEAMS, yfProjectTeams);
		return mapping.findForward(Constants.SUCCESS);
	}

        
	/**
	 * 更新
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward updateYfProjectTeams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("updateYfProjectTeamss");
		YfProjectTeams yfProjectTeams = this.getYfProjectTeams(form);
	        yfProjectTeams.setOperateid(CommonUtil.getCurrentUser(request).getId());
		 yfProjectTeams.setCreateDate(new Date());
		this.yfProjectTeamsService.updateObject(yfProjectTeams);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 查看页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward viewYfProjectTeams(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		log.debug("viewYfProjectTeams");

		YfProjectTeams yfProjectTeams = this.getYfProjectTeams(form);
		yfProjectTeams = this.yfProjectTeamsService.getYfProjectTeams(yfProjectTeams);
		request.setAttribute(Constants.YFPROJECTTEAMS, yfProjectTeams);
		return mapping.findForward(Constants.SUCCESS);
	}

	// get--set
	/**
	 * @return the YfProjectTeamsService
	 */
	public YfProjectTeamsService getYfProjectTeamsService() {
		return this.yfProjectTeamsService;
	}

	/**
	 * @param YfProjectTeamsService
	 *  the YfProjectTeamsService to set
	 */
	public void setYfProjectTeamsService(YfProjectTeamsService yfProjectTeamsService) {
		this.yfProjectTeamsService = yfProjectTeamsService;
	}

	/**
	 * 获取YfProjectTeams实体
	 * @param ActionForm
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 * @return the YfProjectTeams
	 */
	public YfProjectTeams getYfProjectTeams(ActionForm form) throws IllegalAccessException, InvocationTargetException {
		YfProjectTeamsForm yfProjectTeamsForm = (YfProjectTeamsForm) form;
		yfProjectTeams = new YfProjectTeams();
		BeanUtils.copyProperties(yfProjectTeams, yfProjectTeamsForm);
		return yfProjectTeams;
	}
    
        public void setYfProjectTeams(YfProjectTeams yfProjectTeams) {
		this.yfProjectTeams = yfProjectTeams;
	}

}
